home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 027a / agraph.zip / DEMO2.PRG < prev   
Text File  |  1991-05-16  |  3KB  |  69 lines

  1. ************************************************************************
  2. * DEMO2 - Autographing                  5/1/91
  3. * Peter M. Freese                       Pinnacle Publishing, Inc.
  4. *
  5. * Example program which allows you to to dynamically move and resize a
  6. * graph.  This basically shows off the autographing function and gives
  7. * you a good feel for what it can do.  Experiment!  Try modifying the
  8. * DEMO.DBF data to see how the data affects the graph and scaling.
  9. *
  10. * Note that most of this code is just processing the different
  11. * keystrokes, and that all the graphing is still taken care of with a
  12. * single function call.
  13. ************************************************************************
  14.  
  15. #include "inkey.ch"
  16. local data := {}, xlabels := {}
  17. // patterns and colors for 2 groups
  18. local attributes := { {6,9}, {3,12} }   // icons and colors
  19. local redraw := .T.                     // force initial display
  20. local x := 675                          // initial graph coords
  21. local y := 500
  22. local w := 1150                         // initial graph size
  23. local h := 800
  24. local v
  25.  
  26. use demo
  27.  
  28. // store data in arrays
  29. DBEVAL( {|| AADD(data,{score1,score2}),AADD(xlabels,name) })
  30.  
  31. sethires(0)                             // switch to graphics modes
  32.  
  33. do while .T.
  34.   if redraw
  35.     clrscreen()
  36.     // draw graph centered at x,y
  37.     AutoLineGraph(data,w,h,x-w/2,y-h/2,attributes)
  38.     AutoLabel(xlabels)
  39.   end
  40.   k := inkey(0)                         // wait for a keypress
  41.   redraw := .T.                         // assume we'll be redrawing
  42.   do case
  43.   // now modify the origin or the size, based on what key was pressed
  44.   case k = K_ESC
  45.     exit                                // if ESC pressed, time to leave
  46.   case k = K_LEFT
  47.     x -= 50                             // move 50 left
  48.   case k = K_RIGHT
  49.     x += 50                             // move 50 right
  50.   case k = K_UP
  51.     y += 50                             // move 50 up
  52.   case k = K_DOWN
  53.     y -= 50                             // move 50 down
  54.   case k = K_CTRL_LEFT
  55.     w := max(w-50,50)                   // decrease width by 50
  56.   case k = K_CTRL_RIGHT
  57.     w += 50                             // increase width by 50
  58.   case k = K_PGDN
  59.     h := max(h-50,50)                   // decrease height by 50
  60.   case k = K_PGUP
  61.     h += 50                             // increase height by 50
  62.   otherwise
  63.     // if no valid key was pressed, we don't need to redraw the graph
  64.     redraw := .F.
  65.   end
  66. end
  67. settext()                               // return to text mode
  68.  
  69.